import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router'
import Layout from '@/layouts'

const routes: RouteRecordRaw[] = [
  {
    path: '/login',
    name: 'Login',
    component: () => import('@/views/login'),
    meta: { title: '登录', hidden: true },
    props: route => ({ redirect: route.query.redirect })
  },
  {
    path: '/product',
    name: 'Product',
    component: Layout,
    meta: { title: '产品系统', icon: 'AddBoxOutlined' },
    redirect: '/product/list',
    children: [
      {
        path: 'list',
        name: 'ProductList',
        meta: { title: '产品系统列表' },
        component: () => import('views/product/index.vue')
      }
    ]
  },
  {
    path: '/list',
    name: 'List',
    component: Layout,
    meta: { title: '列表', icon: 'AddBoxOutlined' },
    children: [
      {
        path: '',
        meta: { title: '列表', icon: 'AddBoxOutlined' },
        component: () => import('@/views/list')
      }
    ]
  },
  {
    path: '/upload',
    name: 'Upload',
    component: Layout,
    redirect: { name: 'UploadIndex' },
    meta: { title: '上传文件', icon: 'AddBoxOutlined' },
    children: [
      {
        path: '',
        name: 'UploadIndex',
        meta: { title: '上传文件' },
        component: () => import('@/views/upload')
      }
    ]
  },
  {
    path: '/ws',
    name: 'Ws',
    component: Layout,
    meta: { title: 'Ws', icon: 'AddBoxOutlined' },
    redirect: { name: 'WsIndex' },
    children: [
      {
        path: '',
        name: 'WsIndex',
        meta: { title: 'WsIndex' },
        component: () => import('@/views/ws')
      }
    ]
  }
]

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes
})

export default router
